package com.jjy.admin.controller.task;

import cn.hutool.json.JSONUtil;
import com.jjy.admin.domain.JobEntity;
import com.jjy.admin.domain.JobSpiderDTO;
import com.jjy.admin.domain.TaskJob;
import com.jjy.admin.domain.TaskJobDTO;
import com.jjy.admin.service.common.CommonService;
import com.jjy.admin.service.job.JobService;
import com.jjy.admin.service.job.impl.JobServiceImpl;
import com.jjy.admin.service.task.TaskService;
import com.jjy.common.annotation.ApiResource;
import com.jjy.common.domain.PageResult;
import com.jjy.common.domain.R;
import com.jjy.common.enums.ResBizTypeEnum;
import com.jjy.common.utils.SecurityUtils;
import com.jjy.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统功能
 *
 * @author jjy
 */
@RestController
@RequestMapping("/task/job")
@ApiResource(name = "定时任务查询", resBizType = ResBizTypeEnum.SYSTEM)
public class TaskController {
    @Autowired
    private TaskService taskService;
    @Autowired
    private CommonService commonService;

    private static final Logger log = LoggerFactory.getLogger(  TaskController.class);

    /**
     * 分页
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('task:job:list')")
    public R page(TaskJobDTO taskJobDTO) {

        PageResult<TaskJob> page = taskService.page(taskJobDTO);

        return R.ok().put(page);
    }

    /**
     * 删除
     */
    @DeleteMapping("/{jobId}")
    @PreAuthorize("@ss.hasPermi('task:job:delete')")
    public R delete(@PathVariable Long[] jobId) {

        return R.ok(taskService.deleteTasksByIds(jobId));
    }


}